package com.xlisteven.echart.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xlisteven.echart.bean.Phone;
import com.xlisteven.echart.service.IndexService;

@Controller
public class IndexController {

	@Autowired
	IndexService indexService;
	
	@RequestMapping("/")
	public String index(Model model) {
		List<Phone> pList = indexService.findAllPhone();
		model.addAttribute("pList", pList);
		return "index";
	}
	
	@RequestMapping("/queryJSON")
	@ResponseBody
	public List<Map<String,Object>> queryJSON() {
		List<Map<String,Object>> lMap = indexService.queryJSON();
		return lMap;
	}
}
